package cn.lichenfei.jfx.music.common.model;

import lombok.Data;

import java.text.DecimalFormat;

/**
 * @author ChenFei
 * @date 2022年4月25日10:41:35
 */
@Data
public class TimeInfo {

    private static final DecimalFormat DF = new DecimalFormat("00");

    //总秒数
    private Integer totalSeconds;
    //分钟
    private Integer minutes;
    //秒
    private Integer seconds;
    private String timeStr;

    public TimeInfo(int seconds) {
        this.totalSeconds = seconds;
        this.minutes = seconds / 60;
        this.seconds = seconds % 60;
        //设置属性值
        if (seconds >= 99 * 60) {
            this.timeStr = "99:99";
        } else {
            this.timeStr = DF.format(this.minutes) + ":" + DF.format(this.seconds);
        }
    }
}
